/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package clientereligadora.formularios;

import clientereligadora.conexao.Conexao;
import clientereligadora.entidades.Status_Religadora;
import clientereligadora.operacoes.Operacao;
import clientereligadora.paineis.PainelCalibracao;
import clientereligadora.paineis.PainelChart;
import clientereligadora.paineis.PainelConfiguracao;
import clientereligadora.paineis.PainelMaps;
import clientereligadora.paineis.PainelMedidor;
import clientereligadora.principal.PainelModal;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.sql.SQLException;
import java.text.Normalizer;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import org.jdesktop.swingx.JXMapKit;
import org.jdesktop.swingx.JXMapViewer;
import org.jdesktop.swingx.mapviewer.*;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.data.jdbc.JDBCCategoryDataset;
import org.jfree.data.jdbc.JDBCPieDataset;
import org.openstreetmap.gui.jmapviewer.AttributionSupport;
import org.openstreetmap.gui.jmapviewer.DefaultMapController;
import org.openstreetmap.gui.jmapviewer.TileController;
import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import org.openstreetmap.gui.jmapviewer.interfaces.MapMarker;

/**
 *
 * @author leandro.aquino
 */
public final class FormPrincipal extends javax.swing.JFrame {

    private TileFactory factory;
    String username;
    JXMapKit jxMapKit;
    PainelMedidor pMedidor;
    Conexao conn;
    List<GeoPosition> region = new ArrayList<>();
    JLabel hoverLabel = new JLabel("Java");
    //MapScene map = new MapScene();
    Operacao operacao = new Operacao();
    JDBCCategoryDataset dataset;
    JDBCPieDataset dataset1;
    //FORMULARIOS
    JPanel painel1 = new JPanel();
    FormLogin login = new FormLogin();
    PainelMaps painelMaps;
    FormCalibracao formCalibrar;
    PainelModal pm;
    int cod = 1;
    int idReligadora;
    Double lat, lon;
    String status;
    private TileSource tileSource;
    protected TileController tileController;
    protected JSlider zoomSlider;
    protected JButton zoomInButton;
    protected JButton zoomOutButton;
    protected AttributionSupport attribution = new AttributionSupport();
    protected int zoom;
    final HashMap<MapMarker, Integer> markersToIds;
    java.util.Timer timer;
    Locale locale = new Locale("pt", "BR");
    GregorianCalendar calendar = new GregorianCalendar();
    SimpleDateFormat formatador = new SimpleDateFormat("dd' de 'MM' de 'yyyy' - 'HH':'mm'h'", locale);
    Image im;

    /**
     * Creates new form FormPrincipal
     */
    public FormPrincipal(String user, Conexao c) {
        username = user;
        markersToIds = new HashMap<MapMarker, Integer>();

        //conn = new Conexao(user, user, username, user, user);
        formCalibrar = new FormCalibracao();
        painelMaps = new PainelMaps();



        initComponents();
        jLabel35.setBackground(Color.BLACK);
        setaParametros();
        desabilitaCampos();
        painel1.setBackground(Color.WHITE);
        jScrollPane1.setViewportView(painel1);

        setLocationRelativeTo(this);
//        exibirMapa();
        region.add(new GeoPosition(-20.44782, -54.67891));
        region.add(new GeoPosition(-20.44905, -54.66926));
        region.add(new GeoPosition(-20.45579, -54.66994));
        region.add(new GeoPosition(-20.45530, -54.66505));


        MostraHora();
    }

    public void  MostraHora(){
          try{  
         javax.swing.SwingUtilities.invokeLater(new Runnable() {  
            public void run() {   
             new Clock();}  
                     });    
             }  
         catch(Exception e){  
            e.printStackTrace();  
            System.err.println("ERRO interno de execução!");  
            }     
    }
    public void setaParametros() {
        txt_idReligadora.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_estadoChave.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_estadoMaquina.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_falhaTensao.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_falhaCorrente.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_falhaSobrecarga.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_avisoSobrecarga.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_contFalhaTensao.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_contCurtos.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_contSobrecarga.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_contAvisoSobrecarga.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_ccaFA.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_ccaFB.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_ccaFC.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_valSobrFA.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_valSobrFB.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_valSobrFC.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_limiteSobrecarga.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_tempoSobrecarga.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_tensaoFA.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_tensaoFB.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_tensaoFC.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_correnteFA.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_correnteFB.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_correnteFC.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_correnteFN.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_estadoSwitchServico.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_estadoOperacao.setDocument(new FormPrincipal.limitaCaracterInteiro());
        txt_data.setDocument(new FormPrincipal.limitaCaracterData());
        txt_latitude.setDocument(new FormPrincipal.limitaCaracterData());
        txt_longitude.setDocument(new FormPrincipal.limitaCaracterData());

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jXLoginPane1 = new org.jdesktop.swingx.JXLoginPane();
        mapQuestOpenAerialTileSource1 = new org.openstreetmap.gui.jmapviewer.tilesources.MapQuestOpenAerialTileSource();
        osmMercator1 = new org.openstreetmap.gui.jmapviewer.OsmMercator();
        osmTileSource1 = new org.openstreetmap.gui.jmapviewer.tilesources.OsmTileSource();
        jSplitPane1 = new javax.swing.JSplitPane();
        jPanel2 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabPanel = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel27 = new javax.swing.JLabel();
        txt_correnteFB = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        txt_correnteFA = new javax.swing.JTextField();
        jLabel28 = new javax.swing.JLabel();
        txt_correnteFC = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        txt_tensaoFC = new javax.swing.JTextField();
        jLabel25 = new javax.swing.JLabel();
        txt_tensaoFB = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txt_idReligadora = new javax.swing.JTextField();
        txt_limiteSobrecarga = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        txt_tempoSobrecarga = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        txt_falhaSobrecarga = new javax.swing.JTextField();
        txt_tensaoFA = new javax.swing.JTextField();
        jLabel34 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        txt_valSobrFB = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        txt_valSobrFC = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        txt_falhaTensao = new javax.swing.JTextField();
        txt_falhaCorrente = new javax.swing.JTextField();
        txt_estadoChave = new javax.swing.JTextField();
        txt_estadoMaquina = new javax.swing.JTextField();
        txt_avisoSobrecarga = new javax.swing.JTextField();
        txt_contCurtos = new javax.swing.JTextField();
        txt_contFalhaTensao = new javax.swing.JTextField();
        jLabel29 = new javax.swing.JLabel();
        txt_contSobrecarga = new javax.swing.JTextField();
        txt_contAvisoSobrecarga = new javax.swing.JTextField();
        txt_ccaFA = new javax.swing.JTextField();
        txt_ccaFB = new javax.swing.JTextField();
        txt_ccaFC = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        txt_valSobrFA = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        txt_estadoOperacao = new javax.swing.JTextField();
        txt_estadoSwitchServico = new javax.swing.JTextField();
        txt_correnteFN = new javax.swing.JTextField();
        txt_data = new javax.swing.JTextField();
        jLabel33 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        txt_latitude = new javax.swing.JTextField();
        jLabel32 = new javax.swing.JLabel();
        txt_longitude = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JSeparator();
        jSeparator4 = new javax.swing.JSeparator();
        jButton14 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel35 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("GERENCIAMENTO RELIGADORA");
        setBackground(new java.awt.Color(204, 224, 220));

        jSplitPane1.setBackground(new java.awt.Color(204, 224, 220));
        jSplitPane1.setBorder(null);
        jSplitPane1.setDividerLocation(95);
        jSplitPane1.setDividerSize(0);
        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        jSplitPane1.setOneTouchExpandable(true);
        jSplitPane1.setPreferredSize(new java.awt.Dimension(800, 642));

        jPanel2.setBackground(new java.awt.Color(204, 224, 220));

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Maps.png"))); // NOI18N
        jButton2.setToolTipText("Visualizar Religadoras");
        jButton2.setBorder(null);
        jButton2.setContentAreaFilled(false);
        jButton2.setFocusPainted(false);
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton2MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton2MouseExited(evt);
            }
        });
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Editar.png"))); // NOI18N
        jButton4.setToolTipText("Propriedades da Religadora");
        jButton4.setBorder(null);
        jButton4.setBorderPainted(false);
        jButton4.setContentAreaFilled(false);
        jButton4.setFocusPainted(false);
        jButton4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton4MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton4MouseExited(evt);
            }
        });
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Info1.png"))); // NOI18N
        jButton5.setToolTipText("Gráficos");
        jButton5.setBorder(null);
        jButton5.setBorderPainted(false);
        jButton5.setContentAreaFilled(false);
        jButton5.setFocusPainted(false);
        jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton5MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton5MouseExited(evt);
            }
        });
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Users.png"))); // NOI18N
        jButton9.setToolTipText("Configurções Usuarios");
        jButton9.setBorder(null);
        jButton9.setContentAreaFilled(false);
        jButton9.setFocusPainted(false);
        jButton9.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton9MouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton9MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton9MouseExited(evt);
            }
        });
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Home.png"))); // NOI18N
        jButton8.setToolTipText("Visualizar Religadoras");
        jButton8.setBorder(null);
        jButton8.setContentAreaFilled(false);
        jButton8.setFocusPainted(false);
        jButton8.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton8MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton8MouseExited(evt);
            }
        });
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Calibrar2.png"))); // NOI18N
        jButton10.setToolTipText("Calibração");
        jButton10.setBorder(null);
        jButton10.setBorderPainted(false);
        jButton10.setContentAreaFilled(false);
        jButton10.setFocusPainted(false);
        jButton10.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton10MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton10MouseExited(evt);
            }
        });
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Medidor.png"))); // NOI18N
        jButton6.setToolTipText("Propriedades dos Medidores");
        jButton6.setBorder(null);
        jButton6.setBorderPainted(false);
        jButton6.setContentAreaFilled(false);
        jButton6.setFocusPainted(false);
        jButton6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton6MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton6MouseExited(evt);
            }
        });
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Sat.png"))); // NOI18N
        jButton11.setToolTipText("Gráficos");
        jButton11.setBorder(null);
        jButton11.setBorderPainted(false);
        jButton11.setContentAreaFilled(false);
        jButton11.setFocusPainted(false);
        jButton11.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton11MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton11MouseExited(evt);
            }
        });
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        jButton12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Config.png"))); // NOI18N
        jButton12.setToolTipText("Configuração");
        jButton12.setBorder(null);
        jButton12.setBorderPainted(false);
        jButton12.setContentAreaFilled(false);
        jButton12.setFocusPainted(false);
        jButton12.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton12MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton12MouseExited(evt);
            }
        });
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap(15, Short.MAX_VALUE)
                .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(15, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE)
                            .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE)
                            .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE)
                            .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE)
                            .addComponent(jButton6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE)
                            .addComponent(jButton12, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jButton11, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
                .addContainerGap())
        );

        jSplitPane1.setLeftComponent(jPanel2);

        jScrollPane1.setPreferredSize(new java.awt.Dimension(907, 311));
        jScrollPane1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                jScrollPane1MouseMoved(evt);
            }
        });

        tabPanel.setBackground(new java.awt.Color(255, 255, 255));
        tabPanel.setForeground(new java.awt.Color(0, 0, 71));
        tabPanel.setPreferredSize(new java.awt.Dimension(795, 465));

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jPanel1.setPreferredSize(new java.awt.Dimension(742, 489));

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel27.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel27.setForeground(new java.awt.Color(0, 0, 71));
        jLabel27.setText("Corrente fase C:");

        txt_correnteFB.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel26.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel26.setForeground(new java.awt.Color(0, 0, 71));
        jLabel26.setText("Corrente fase B:");

        txt_correnteFA.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel28.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel28.setForeground(new java.awt.Color(0, 0, 71));
        jLabel28.setText("Corrente Fase neutro:");

        txt_correnteFC.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel2.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(0, 0, 71));
        jLabel2.setText("IP:");

        jLabel3.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(0, 0, 71));
        jLabel3.setText("Nome:");

        jLabel1.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 0, 71));
        jLabel1.setText("ID:");

        txt_tensaoFC.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel25.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel25.setForeground(new java.awt.Color(0, 0, 71));
        jLabel25.setText("Corrente fase A:");

        txt_tensaoFB.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel24.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel24.setForeground(new java.awt.Color(0, 0, 71));
        jLabel24.setText("Tensao Fase C:");

        jTextField3.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel4.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(0, 0, 71));
        jLabel4.setText("Firmware:");

        txt_idReligadora.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        txt_idReligadora.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txt_idReligadoraKeyPressed(evt);
            }
        });

        txt_limiteSobrecarga.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel20.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel20.setForeground(new java.awt.Color(0, 0, 71));
        jLabel20.setText("Limite Sobrecarga:");

        txt_tempoSobrecarga.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel21.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel21.setForeground(new java.awt.Color(0, 0, 71));
        jLabel21.setText("Tempo Sobrecarga:");

        txt_falhaSobrecarga.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_tensaoFA.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel34.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel34.setForeground(new java.awt.Color(0, 0, 71));
        jLabel34.setText("Falha de Corrente:");

        jLabel22.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel22.setForeground(new java.awt.Color(0, 0, 71));
        jLabel22.setText("Tensao Fase A:");

        jLabel23.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel23.setForeground(new java.awt.Color(0, 0, 71));
        jLabel23.setText("Tensao Fase B:");

        jLabel6.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel6.setForeground(new java.awt.Color(0, 0, 71));
        jLabel6.setText("Estado Maquina:");

        jLabel7.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(0, 0, 71));
        jLabel7.setText("Falha de tensao:");

        jLabel8.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(0, 0, 71));
        jLabel8.setText("Falha de Sobrecarga:");

        jLabel9.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(0, 0, 71));
        jLabel9.setText("Aviso Sobrecarga:");

        jTextField4.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_valSobrFB.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jTextField5.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel19.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel19.setForeground(new java.awt.Color(0, 0, 71));
        jLabel19.setText("Valor Sobrecarga F.C:");

        txt_valSobrFC.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel5.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(0, 0, 71));
        jLabel5.setText("Estado Chave:");

        jLabel10.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel10.setForeground(new java.awt.Color(0, 0, 71));
        jLabel10.setText("Contador Aviso Sobrecarga:");

        jLabel11.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(0, 0, 71));
        jLabel11.setText("Corrente Curto Atual F.A:");

        jLabel12.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel12.setForeground(new java.awt.Color(0, 0, 71));
        jLabel12.setText("Contador Sobrecarga:");

        jLabel15.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel15.setForeground(new java.awt.Color(0, 0, 71));
        jLabel15.setText("Corrente Curto Atual F.B:");

        jLabel16.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel16.setForeground(new java.awt.Color(0, 0, 71));
        jLabel16.setText("Corrente Curto Atual F.C:");

        jLabel13.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel13.setForeground(new java.awt.Color(0, 0, 71));
        jLabel13.setText("Contador Curtos:");

        jLabel14.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel14.setForeground(new java.awt.Color(0, 0, 71));
        jLabel14.setText("Contador Falha Tensao:");

        txt_falhaTensao.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_falhaCorrente.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_estadoChave.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_estadoMaquina.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_avisoSobrecarga.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_contCurtos.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_contFalhaTensao.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel29.setForeground(new java.awt.Color(0, 0, 71));
        jLabel29.setText("Estado Switch Serviço:");

        txt_contSobrecarga.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_contAvisoSobrecarga.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_ccaFA.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_ccaFB.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_ccaFC.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel17.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel17.setForeground(new java.awt.Color(0, 0, 71));
        jLabel17.setText("Valor Sobrecarga F.A:");

        txt_valSobrFA.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel18.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jLabel18.setForeground(new java.awt.Color(0, 0, 71));
        jLabel18.setText("Valor Sobrecarga F.B:");

        jLabel30.setForeground(new java.awt.Color(0, 0, 71));
        jLabel30.setText("Estado Operação:");

        txt_estadoOperacao.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_estadoSwitchServico.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_correnteFN.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        txt_data.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel33.setForeground(new java.awt.Color(0, 0, 71));
        jLabel33.setText("Data:");

        jLabel31.setForeground(new java.awt.Color(0, 0, 71));
        jLabel31.setText("Latitude:");

        txt_latitude.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jLabel32.setForeground(new java.awt.Color(0, 0, 71));
        jLabel32.setText("Longitude:");

        txt_longitude.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/14_alterar.png"))); // NOI18N
        jButton3.setBorder(null);
        jButton3.setBorderPainted(false);
        jButton3.setContentAreaFilled(false);
        jButton3.setFocusPainted(false);
        jButton3.setFocusable(false);
        jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton3MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton3MouseExited(evt);
            }
        });
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/27 -Add.png"))); // NOI18N
        jButton1.setBorder(null);
        jButton1.setBorderPainted(false);
        jButton1.setContentAreaFilled(false);
        jButton1.setFocusable(false);
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton1MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton1MouseExited(evt);
            }
        });
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/26 -delete.png"))); // NOI18N
        jButton7.setBorder(null);
        jButton7.setBorderPainted(false);
        jButton7.setContentAreaFilled(false);
        jButton7.setFocusable(false);
        jButton7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton7MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton7MouseExited(evt);
            }
        });

        jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jSeparator4.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jButton14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Busca2.png"))); // NOI18N
        jButton14.setBorder(null);
        jButton14.setBorderPainted(false);
        jButton14.setContentAreaFilled(false);
        jButton14.setFocusable(false);
        jButton14.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton14MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButton14MouseExited(evt);
            }
        });
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(17, 17, 17)
                                .addComponent(txt_idReligadora, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 713, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(jButton1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton7))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel34, javax.swing.GroupLayout.Alignment.TRAILING))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txt_contSobrecarga, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txt_contCurtos, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addGap(1, 1, 1)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(txt_falhaCorrente, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(txt_falhaTensao, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(txt_estadoMaquina, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(txt_estadoChave, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addComponent(txt_contFalhaTensao, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txt_avisoSobrecarga, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txt_falhaSobrecarga, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txt_contAvisoSobrecarga, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, Short.MAX_VALUE)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel23)
                                            .addComponent(jLabel22))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txt_tensaoFB, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(txt_tensaoFA, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel16)
                                        .addGap(18, 18, 18)
                                        .addComponent(txt_ccaFC, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel15, javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txt_ccaFA, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(txt_ccaFB, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel21)
                                            .addComponent(jLabel20)
                                            .addComponent(jLabel19)
                                            .addComponent(jLabel18)
                                            .addComponent(jLabel17))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txt_tempoSobrecarga, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(txt_limiteSobrecarga, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(txt_valSobrFC, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(txt_valSobrFB, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(txt_valSobrFA, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))))))
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 4, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel32)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(txt_longitude, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                            .addComponent(jLabel31)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(txt_latitude, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                            .addComponent(jLabel33)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(txt_data, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                            .addComponent(jLabel30)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(txt_estadoOperacao, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(jPanel4Layout.createSequentialGroup()
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jLabel29)
                                                .addComponent(jLabel28))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(txt_correnteFN, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(txt_estadoSwitchServico, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel26)
                                            .addComponent(jLabel27))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(txt_correnteFC, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(txt_correnteFB, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel24)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(txt_tensaoFC, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel25)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(txt_correnteFA, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(20, 20, 20))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton14)
                                .addGap(79, 79, 79))))))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap(14, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3)
                    .addComponent(txt_idReligadora, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 20, Short.MAX_VALUE)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel4Layout.createSequentialGroup()
                            .addGap(5, 5, 5)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel4Layout.createSequentialGroup()
                                    .addGap(32, 32, 32)
                                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel15)
                                        .addComponent(txt_ccaFB, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(jPanel4Layout.createSequentialGroup()
                                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(txt_tensaoFC, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel24))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(txt_correnteFA, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel25)))
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(txt_ccaFA, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel11)))
                                    .addGap(15, 15, 15)
                                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(txt_valSobrFA, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel17))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(txt_valSobrFB, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel18))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(txt_valSobrFC, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel19))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(txt_limiteSobrecarga, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel20))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(txt_tempoSobrecarga, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel21))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(txt_tensaoFA, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel22))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(txt_tensaoFB, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel23)))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(txt_correnteFB, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel26)
                                                .addComponent(txt_ccaFC, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel16))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(txt_correnteFC, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel27))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel28)
                                                .addComponent(txt_correnteFN, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel29)
                                                .addComponent(txt_estadoSwitchServico, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel30)
                                                .addComponent(txt_estadoOperacao, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel33)
                                                .addComponent(txt_data, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel31)
                                                .addComponent(txt_latitude, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel32)
                                                .addComponent(txt_longitude, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)))))))
                        .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 304, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel4Layout.createSequentialGroup()
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel5)
                                .addComponent(txt_estadoChave, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(15, 15, 15)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel6)
                                .addComponent(txt_estadoMaquina, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(15, 15, 15)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel7)
                                .addComponent(txt_falhaTensao, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(15, 15, 15)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txt_falhaCorrente, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel34))
                            .addGap(15, 15, 15)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(txt_falhaSobrecarga, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel8))
                            .addGap(15, 15, 15)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txt_avisoSobrecarga, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel9))
                            .addGap(15, 15, 15)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txt_contFalhaTensao, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel14))
                            .addGap(15, 15, 15)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txt_contCurtos, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel13))
                            .addGap(15, 15, 15)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txt_contSobrecarga, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel12))
                            .addGap(15, 15, 15)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txt_contAvisoSobrecarga, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel10)))))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton1)
                    .addComponent(jButton3)
                    .addComponent(jButton7)
                    .addComponent(jButton14))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(66, Short.MAX_VALUE)
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap(66, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(28, Short.MAX_VALUE)
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        tabPanel.addTab("RELIGADORA", jPanel1);

        jScrollPane1.setViewportView(tabPanel);

        jSplitPane1.setBottomComponent(jScrollPane1);

        jPanel3.setBackground(new java.awt.Color(204, 224, 220));

        jLabel35.setBackground(new java.awt.Color(0, 0, 0));
        jLabel35.setFont(new java.awt.Font("DS-Digital", 1, 24)); // NOI18N
        jLabel35.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel35.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel35, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(46, Short.MAX_VALUE)
                .addComponent(jLabel35, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jMenu1.setText("Arquivo");

        jMenu4.setText("Configuração");

        jMenuItem3.setText("Calibrar Religadora");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem3);

        jMenu1.add(jMenu4);
        jMenu1.add(jSeparator1);

        jMenuItem2.setText("Logoff: "+username);
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Editar");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 895, Short.MAX_VALUE)
            .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(3, 3, 3)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed

        int opt = JOptionPane.showConfirmDialog(null, "DESEJA EFETUAR LOGOFF DO USUARIO '" + username.toUpperCase() + "'",
                "LOGOFF", JOptionPane.YES_NO_OPTION);
        if (opt == JOptionPane.YES_OPTION) {
            try {
                Thread.sleep(1000);
                login.setVisible(true);
                login.upGradient();
            } catch (InterruptedException ex) {
                Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, username, ex);
            }
            this.dispose();
        } else {
        }
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    public void mouseMoved(MouseEvent e) {
        hoverLabel = new JLabel("Java");
        hoverLabel.setVisible(false);
        JXMapViewer map = new JXMapKit().getMainMap();
        //location of Java
        GeoPosition gp = new GeoPosition(-20.44782, -54.67891);
        //convert to world bitmap
        Point2D gp_pt = map.getTileFactory().geoToPixel(gp, map.getZoom());
        //convert to screen
        jxMapKit.setMiniMapVisible(true);
        Rectangle rect = map.getViewportBounds();
        Point converted_gp_pt = new Point((int) gp_pt.getX() - rect.x,
                (int) gp_pt.getY() - rect.y);

        //check if near the mouse

        hoverLabel.setLocation(converted_gp_pt);
        hoverLabel.setVisible(true);

        //System.out.println("converted_gp_pt: "+converted_gp_pt);
        System.out.println("map.getAddressLocation(): " + gp_pt);


    }

    public void PieChart(String tituloAplicacao, String tituloChart) {

        PieDataset dataset = createDataset();
//          JFreeChart chart = 

    }
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        jScrollPane1.setViewportView(painelMaps);
        listaMakers();
        atualizaMapa();

        // PainelMaps.jMapViewer1.setDisplayToFitMapMarkers();


    }//GEN-LAST:event_jButton2ActionPerformed

    public void listaMakers() {
        DefaultMapController mapController = new DefaultMapController(PainelMaps.jMapViewer1);
        mapController.setMovementMouseButton(MouseEvent.BUTTON1);

//           Set<Waypoint> waypoints =  new HashSet<>();
//    waypoints.add(new Waypoint(-20.44905, -54.66926));
//        waypoints.add(new Waypoint(-20.468833, -54.616597));
//        int lat = (int) -20.463412;
//        int lon = (int) -54.646090;
//
//   // double teste[][] = new double [-20.463412][-54.646090];
//     //System.out.println(matriz);
        painelMaps.exibirMapa1(-20.44782, -54.67891);
//     //jMapViewer1.addMapMarker(null);
//     PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot(lat, lon));
//     PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot(Color.RED, -20.44905, -54.66926));
//     PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot(Color.GREEN, -20.455529, -54.673797));
//     PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot(Color.GREEN, -20.463412, -54.646090));
//     List<MapMarker> teste = PainelMaps.jMapViewer1.getMapMarkerList();
//     System.out.println("lista: " + teste);
        try {
            teste();
        } catch (Exception e) {
            System.out.println(e);
        }


    }

    public void setTileSource(TileSource tileSource) {
        int MAX_ZOOM = 22;
        int MIN_ZOOM = 0;
        if (tileSource.getMaxZoom() > MAX_ZOOM) {
            throw new RuntimeException("Maximum zoom level too high");
        }
        if (tileSource.getMinZoom() < MIN_ZOOM) {
            throw new RuntimeException("Minumim zoom level too low");
        }
        this.tileSource = tileSource;
        tileController.setTileSource(tileSource);
        zoomSlider.setMinimum(tileSource.getMinZoom());
        zoomSlider.setMaximum(tileSource.getMaxZoom());
        tileController.cancelOutstandingJobs();
        if (zoom > tileSource.getMaxZoom()) {
            // setZoom(tileSource.getMaxZoom());
        }

        attribution.initialize(tileSource);
        repaint();
    }

    public void teste() {
    }
    Painter<JXMapViewer> polygonOverlay = new Painter<JXMapViewer>() {
        @Override
        public void paint(Graphics2D g, JXMapViewer map, int width, int height) {
            g = (Graphics2D) g.create();
            //convert from viewport to world bitmap
            Rectangle rect = map.getViewportBounds();
            g.translate(-rect.x, -rect.y);

            //create a polygon
            Polygon poly = new Polygon();
            for (GeoPosition gp : region) {
                //convert geo to world bitmap pixel
                Point2D pt = map.getTileFactory().geoToPixel(gp, map.getZoom());
                poly.addPoint((int) pt.getX(), (int) pt.getY());
            }

            //do the drawing
            g.setColor(new Color(255, 0, 0, 100));
            g.fill(poly);
            g.setColor(Color.RED);
            g.draw(poly);

            g.dispose();
        }
    };

    public Set<Waypoint> doInBackground() {


        List<Status_Religadora> listaRelisgadora = operacao.listar();
        Set<Waypoint> waypoints = new HashSet<>();
        for (int i = 0; i < listaRelisgadora.size(); i++) {
            System.out.println("teste" + listaRelisgadora.get(i).getId_religadora());
            System.out.println("teste" + listaRelisgadora.get(i).getLat());
            System.out.println("teste" + listaRelisgadora.get(i).getLon());
            idReligadora = listaRelisgadora.get(i).getId_religadora();
            lat = Double.parseDouble(listaRelisgadora.get(i).getLat());
            lon = Double.parseDouble(listaRelisgadora.get(i).getLon());
            waypoints.add(new Waypoint(lat, lon));
        }


        return waypoints;  // return your result

    }

    public synchronized void addWaypoint() {
        // 1     
        List<Status_Religadora> listaRelisgadora = operacao.listar();
        if (listaRelisgadora.isEmpty()) {
            jxMapKit.getMainMap().setOverlayPainter(null);
            System.out.println("Lista vazia!");
        } else {
            Set<Waypoint> waypoints = new HashSet<>();


            for (int i = 0; i < listaRelisgadora.size(); i++) {
                lat = Double.parseDouble(listaRelisgadora.get(i).getLat());
                lon = Double.parseDouble(listaRelisgadora.get(i).getLon());
                idReligadora = listaRelisgadora.get(i).getId_religadora();
                status = listaRelisgadora.get(i).getStatus();

                if (status.equals("CANC")) {
                    im = new ImageIcon(getClass().getResource("/imagens/red.png")).getImage();
                }
                if (status.equals("ATIVO")) {
                    im = new ImageIcon(getClass().getResource("/imagens/green.png")).getImage();
                }
                if (status.equals("OPEN")) {
                    im = new ImageIcon(getClass().getResource("/imagens/yellow.png")).getImage();
                }

                System.out.println("Posicao: " + i + " - ID: " + idReligadora + " - Status: " + status);
                waypoints.add(new Waypoint(lat, lon));

                //crate a WaypointPainter to draw the point
                WaypointPainter painter = new WaypointPainter();
                painter.setWaypoints(waypoints);






                painter.setRenderer(new WaypointRenderer() {
                    public boolean paintWaypoint(Graphics2D g, JXMapViewer map, Waypoint wp) {
                        g.setColor(Color.RED);

                        g.drawImage(im, -40, -40, null);

                        //    g.drawLine(-5, -5, +5, +5);
//                    g.drawLine(-5, +5, +5, -5);
                        g.setPaint(new Color(0, 0, 0, 165));
                        //(alinhamento,xx,altera largura,xx,xx,xx)       
                        g.fillRoundRect(-70, -53, 80, 14, 7, 7);
                        g.setPaint(Color.WHITE);
                        g.drawString("Religadora " + idReligadora + " - " + status, -60, -43);
                        return true;
                    }
                });

                jxMapKit.getMainMap().setOverlayPainter(painter);
            }
        }




    }

    public void goCg() {
        jxMapKit.setAddressLocation(new GeoPosition(-20.468833, -54.616597));
        jxMapKit.setZoom(11);
    }

    protected void succeeded(Set<Waypoint> waypoints) {
        // move to the center
        jxMapKit.setAddressLocation(new GeoPosition(-20.468833, -54.616597));

        WaypointPainter painter = new WaypointPainter();

        //set the waypoints
        painter.setWaypoints(waypoints);

        //create a renderer
        painter.setRenderer(new WaypointRenderer() {
            public boolean paintWaypoint(Graphics2D g, JXMapViewer map, Waypoint wp) {
                Waypoint wwp = (Waypoint) wp;

                //draw tab
                g.setPaint(new Color(0, 0, 255, 200));
                Polygon triangle = new Polygon();
                triangle.addPoint(0, 0);
                triangle.addPoint(11, 11);
                triangle.addPoint(-11, 11);
                g.fill(triangle);
                int width = (int) g.getFontMetrics().getStringBounds("" + idReligadora, g).getWidth();
                g.fillRoundRect(-width / 2 - 5, 10, width + 10, 20, 10, 10);

                //draw text w/ shadow
                g.setPaint(Color.BLACK);
                g.drawString("" + idReligadora, -width / 2 - 1, 26 - 1); //shadow
                g.drawString("" + idReligadora, -width / 2 - 1, 26 - 1); //shadow
                g.setPaint(Color.WHITE);
                g.drawString("" + idReligadora, -width / 2, 26); //text
                return false;
            }
        });
        jxMapKit.getMainMap().setOverlayPainter(painter);
        jxMapKit.getMainMap().repaint();
    }
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        jScrollPane1.setViewportView(tabPanel);

    }//GEN-LAST:event_jButton4ActionPerformed

    private void jScrollPane1MouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jScrollPane1MouseMoved
        // TODO add your handling code here:
    }//GEN-LAST:event_jScrollPane1MouseMoved

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed

        primeiroGrafico();
//        mostraGrafico();
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
//        pm = new PainelModal(formCalibrar, "CALIBRAR RELIGADORAS", Dialog.ModalityType.DOCUMENT_MODAL);
//        pm.setContentPane(formCalibrar.getContentPane());
//        pm.setBounds(formCalibrar.getBounds());
//        pm.setVisible(true);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void txt_idReligadoraKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_idReligadoraKeyPressed
        int key = evt.getKeyCode();
        if (key == KeyEvent.VK_ENTER) {
            idReligadora = Integer.parseInt(txt_idReligadora.getText());
            System.out.println(idReligadora);
            getGadosReligadora(idReligadora);
        }
    }//GEN-LAST:event_txt_idReligadoraKeyPressed

    private void jButton5MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton5MouseEntered
        setCursor(new Cursor(Cursor.HAND_CURSOR));        // TODO add your handling code here:
    }//GEN-LAST:event_jButton5MouseEntered

    private void jButton5MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton5MouseExited
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }//GEN-LAST:event_jButton5MouseExited

    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton2MouseClicked

    private void jButton2MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseEntered
        setCursor(new Cursor(Cursor.HAND_CURSOR));
    }//GEN-LAST:event_jButton2MouseEntered

    private void jButton2MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseExited
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }//GEN-LAST:event_jButton2MouseExited

    private void jButton4MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton4MouseEntered
        setCursor(new Cursor(Cursor.HAND_CURSOR));
    }//GEN-LAST:event_jButton4MouseEntered

    private void jButton4MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton4MouseExited
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }//GEN-LAST:event_jButton4MouseExited

    private void jButton9MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton9MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton9MouseClicked

    private void jButton9MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton9MouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton9MouseEntered

    private void jButton9MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton9MouseExited
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton9MouseExited

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        FormGrafico nf;
        try {
            nf = new FormGrafico();
            nf.setVisible(true);
        } catch (SQLException ex) {
            Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }



        // TODO add your handling code here:
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton8MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton8MouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton8MouseEntered

    private void jButton8MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton8MouseExited
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton8MouseExited

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed


        mostraMapa();


        atualizaMapa();
        // succeeded(doInBackground());

    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton10MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton10MouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton10MouseEntered

    private void jButton10MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton10MouseExited
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton10MouseExited

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        PainelCalibracao painelCalibracao = new PainelCalibracao();
        jScrollPane1.setViewportView(painelCalibracao);
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton6MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton6MouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton6MouseEntered

    private void jButton6MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton6MouseExited
    }//GEN-LAST:event_jButton6MouseExited
    public synchronized void atualizaMapa() {
        // executa tarefa a cada 30 segundos


//        try {
//            long tempo1 = (1000 * 15);
//        long tempo2 = (1000 * 10);
//            timer = new java.util.Timer();
//            TimerTask tarefa = new TimerTask() {
//                @Override
//                public void run() {
//                    try {
//                        Date data = new Date();
//                        System.out.println("Teste Agendador: \n" + formatador.format(data));
//                        teste();
//                        //chamar metodo    
//                    } catch (Exception e) {
//                        e.printStackTrace();
//                    }
//                }
//            };
//            timer.scheduleAtFixedRate(tarefa, tempo1, tempo2);
//        } catch (Exception e) {
//        }
// 
//        Teste t = new Teste();
//        Thread t1 = new Thread(t);
//        t1.start();
//        try {
//            //        try{
//                        t1.currentThread().sleep(1000);  
//            //        }catch(InterruptedException  e){
//            //        }
//            //        }
//        } catch (InterruptedException ex) {
//            Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
//        }


        new Thread() {
            public void run() {
                while (true) {

                    teste2();
                    try {
                        sleep(10000);//Para por 30 segundo  
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        }.start();



    }

    public synchronized void teste2() {
        Set<Waypoint> waypoints = new HashSet<>();
        List<Status_Religadora> listaRelisgadora = new Operacao().listar();
        for (int i = 0; i < listaRelisgadora.size(); i++) {

            idReligadora = listaRelisgadora.get(i).getId_religadora();
            lat = Double.parseDouble(listaRelisgadora.get(i).getLat());
            lon = Double.parseDouble(listaRelisgadora.get(i).getLon());
            status = listaRelisgadora.get(i).getStatus();

            System.out.println("Passou2");
//            System.out.println("Longitude" + lon);
            //waypoints.add(new Waypoint(lat, lon));
            if ("CANC".equals(status)) {
                //  PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot(Color.RED, lat, lon));
                MapMarkerDot1 CANC = new MapMarkerDot1(Color.RED, idReligadora, lat, lon, status);
                // String a  =new MapMarkerDot1(Color.RED,idReligadora, lat, lon, status).toString();

                PainelMaps.jMapViewer1.addMapMarker(CANC);

                //                   PainelMaps.jMapViewer1.setToolTipText(a);
//PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot(Color.RED,idReligadora, lat, lon, status));
//PainelMaps.jMapViewer1.add
//                System.out.println(idReligadora + ": "+lat+ " : "+lon+ " : "+status);

            } else if ("OPEN".equals(status)) {
                // PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot(Color.YELLOW, lat, lon));
                MapMarkerDot1 OPEN = new MapMarkerDot1(Color.YELLOW, idReligadora, lat, lon, status);

                //  MapMarkerDot1 TESTE = new MapMarkerDot1
                PainelMaps.jMapViewer1.addMapMarker(OPEN);

                // PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot1(Color.YELLOW,idReligadora, lat, lon, status));
                // System.out.println(idReligadora + ": "+lat+ " : "+lon+ " : "+status);
            } else {
                //PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot(Color.GREEN, lat, lon));
                MapMarkerDot1 ATIVO = new MapMarkerDot1(Color.GREEN, idReligadora, lat, lon, status);
                PainelMaps.jMapViewer1.addMapMarker(ATIVO);
                //   PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot1(Color.GREEN,idReligadora, lat, lon, status));
                System.out.println(idReligadora + ": " + lat + " : " + lon + " : " + status);
            }

            System.out.println("Posicao: " + i + " - ID: " + idReligadora + " - Status: " + status);

//                JMenuItem item3 = new JMenuItem("" + lat + "" + lon);
//                JPopupMenu popup = new JPopupMenu();
//                popup.add(item3);
//                // popup.show();
//                //  jMapViewer1.add(popup);]
//
//                popup.show(PainelMaps.jMapViewer1, 50, 50);
//               
//            

            waypoints.add(new Waypoint(lat, lon));
        }


        WaypointPainter painter = new WaypointPainter();
        painter.setWaypoints(waypoints);


        listaRelisgadora.removeAll(listaRelisgadora);
    }

    public synchronized void mostraMapa() {

        jxMapKit = new JXMapKit();
        jxMapKit.setDefaultProvider(JXMapKit.DefaultProviders.OpenStreetMaps);
        jxMapKit.setCenterPosition(new GeoPosition(-20.468833, -54.616597));
        jxMapKit.getMainMap().setRecenterOnClickEnabled(true);
        jxMapKit.setZoom(5);
        jxMapKit.setAddressLocationShown(true);
        // jxMapKit.getMainMap().addMouseMotionListener(mouseMotionListener);
        //jxMapKit.getMainMap().setOverlayPainter(waypointSetPainter);
        jxMapKit.setMiniMapVisible(true);
        jxMapKit.setZoomSliderVisible(true);
        //jxMapKit.setZoomButtonsVisible(true);

        //jxMapKit.getMainMap().setPanEnabled(true);
        jScrollPane1.setViewportView(jxMapKit);
        addWaypoint();

// Add a selection painter
//		SelectionAdapter sa = new SelectionAdapter(jMapViewer1); 
//		SelectionPainter sp = new SelectionPainter(sa); 
//		jxMapKit.addMouseListener(sa); 
//		jxMapKit.addMouseMotionListener(sa); 
//		jMapViewer1.setOverlayPainter(sp);
//        SelectionPainter sp = new SelectionPainter();
//        jxMapKit.getMainMap().addMouseListener(sp);
//        jxMapKit.getMainMap().addMouseMotionListener(sp);
        //   jxMapKit.getMainMap().setOverlayPainter(sp);
    }
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed

////        teste();  
        // TODO add your handling code here:
        pMedidor = new PainelMedidor();

        jScrollPane1.setViewportView(pMedidor);
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton11MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton11MouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton11MouseEntered

    private void jButton11MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton11MouseExited
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton11MouseExited

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed

        try {
            PainelChart pchart = new PainelChart();

            jScrollPane1.setViewportView(pchart);
        } catch (SQLException ex) {
            Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jButton11ActionPerformed

    private void jButton12MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton12MouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton12MouseEntered

    private void jButton12MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton12MouseExited
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton12MouseExited

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        PainelConfiguracao painelCfg = new PainelConfiguracao();
        jScrollPane1.setViewportView(painelCfg);

        //        FormConfiguracao fcg = new FormConfiguracao();
//        fcg.setVisible(true);
        //       
////        while (teste == true) {
////            lineChart();
////        }
//           String query = "select evento.id_religadora AS RELIGADORA, evento.tipo_evento AS EVENTO from dataserverreligadora.evento "
//                + "WHERE `data` > 2013-01-04 "
//                + "ORDER BY id_religadora";
//
//        JDBCCategoryDataset dataset1 = null;
//        try {
//            dataset1 = new JDBCCategoryDataset("jdbc:mysql://localhost:3306/dataserverreligadora", "com.mysql.jdbc.Driver",
//                    "root", "ntk1120");
//        } catch (ClassNotFoundException | SQLException ex) {
//            Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
//        }
//        try {
//            dataset1.executeQuery(query);
//        } catch (SQLException ex) {
//            Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
//        }
//        System.out.println(query);
//        System.out.println(dataset1);
//        createChartBar(dataset1);        // TODO add your handling code here:
    }//GEN-LAST:event_jButton12ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        FormVisualizaReligadoras fmVeReligadora;
        try {
            fmVeReligadora = new FormVisualizaReligadoras();
             fmVeReligadora.setVisible(true);
        } catch (SQLException ex) {
            Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
       
        Calendar cal = Calendar.getInstance();
        int data = cal.getTime().getDate();
        int dia = cal.getTime().getDay();
        int hora = cal.getTime().getHours();
        int min = cal.getTime().getMinutes();
        System.out.println("Data: "+ data +" - dia: "+dia +" - hora: "+hora+":"+min);
        
    }//GEN-LAST:event_jButton14ActionPerformed

    private void jButton1MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseEntered
       setCursor(new Cursor(Cursor.HAND_CURSOR));
    }//GEN-LAST:event_jButton1MouseEntered

    private void jButton1MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseExited
      setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }//GEN-LAST:event_jButton1MouseExited

    private void jButton3MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseEntered
      setCursor(new Cursor(Cursor.HAND_CURSOR));
    }//GEN-LAST:event_jButton3MouseEntered

    private void jButton3MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseExited
       setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }//GEN-LAST:event_jButton3MouseExited

    private void jButton7MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton7MouseEntered
        setCursor(new Cursor(Cursor.HAND_CURSOR));
    }//GEN-LAST:event_jButton7MouseEntered

    private void jButton7MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton7MouseExited
       setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }//GEN-LAST:event_jButton7MouseExited

    private void jButton14MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton14MouseEntered
        setCursor(new Cursor(Cursor.HAND_CURSOR));
    }//GEN-LAST:event_jButton14MouseEntered

    private void jButton14MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton14MouseExited
       setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }//GEN-LAST:event_jButton14MouseExited

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    public void lineChart() {
        String query = "select evento.id_religadora, evento.tipo_evento from dataserverreligadora.evento "
                + "WHERE `data` > 2013-01-04 "
                + "ORDER BY id_religadora";

        try {
            dataset = new JDBCCategoryDataset("jdbc:mysql://localhost:3306/dataserverreligadora", "com.mysql.jdbc.Driver",
                    "root", "ntk1120");
        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            //         JDBCPieDataset dataset1 = new JDBCPieDataset("jdbc:mysql://localhost:3306/dataserverreligadora", "com.mysql.jdbc.Driver",
            //                                    "root", "123456");
            //      dataset.executeQuery(query);
            //         
            dataset.executeQuery(query);
        } catch (SQLException ex) {
            Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }


        JFreeChart chart = ChartFactory.createLineChart("Religadora", "id_religadora", "tipo_evento",
                dataset, PlotOrientation.VERTICAL, true, true, false);
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(650, 270));
//                ApplicationFrame f = new ApplicationFrame("Chart");
//                f.setContentPane(chartPanel);
//                f.pack();
        jScrollPane1.setViewportView(new ChartPanel(chart));

    }

    private JFreeChart createChartBar(CategoryDataset dataset) {
        // create the chart...
        final JFreeChart chart = ChartFactory.createBarChart(
                "RELIGADORA - EVENTOS", // chart title
                "TIPO EVENDO", // domain axis label
                "COD RELIGADORA", // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                false, // tooltips?
                false // URLs?
                );

        // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

        // set the background color for the chart...
        chart.setBackgroundPaint(Color.white);

        // get a reference to the plot for further customisation...
        final CategoryPlot plot = chart.getCategoryPlot();
        plot.setBackgroundPaint(Color.WHITE);
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlinePaint(Color.DARK_GRAY);

        // set the range axis to display integers only...
        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

        // disable bar outlines...
        final BarRenderer renderer = (BarRenderer) plot.getRenderer();
        renderer.setDrawBarOutline(false);

        // set up gradient paints for series...
        final GradientPaint gp0 = new GradientPaint(
                0.0f, 0.0f, Color.GREEN,
                0.0f, 0.0f, Color.lightGray);
        final GradientPaint gp1 = new GradientPaint(
                0.0f, 0.0f, Color.RED,
                0.0f, 0.0f, Color.lightGray);
        final GradientPaint gp2 = new GradientPaint(
                0.0f, 0.0f, Color.red,
                0.0f, 0.0f, Color.lightGray);
        renderer.setSeriesPaint(0, gp0);
        renderer.setSeriesPaint(1, gp1);
        renderer.setSeriesPaint(2, gp2);

        final CategoryAxis domainAxis = plot.getDomainAxis();
        domainAxis.setCategoryLabelPositions(
                CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
        // OPTIONAL CUSTOMISATION COMPLETED.
        ChartPanel chartPanel = new ChartPanel(chart);
        jScrollPane1.setViewportView(chartPanel);
        return chart;

    }

    public void mostraGrafico() {
        PieDataset dataset = createDataset();
        // based on the dataset we create the chart
        JFreeChart chart = createChart(dataset, "Primiro Char");
        // we put the chart into a panel
        ChartPanel chartPanel = new ChartPanel(chart);
        // default size
        chartPanel.setPreferredSize(new java.awt.Dimension(650, 270));
        // add it to our application
        setContentPane(chartPanel);
    }

    public void primeiroGrafico() {
        DefaultPieDataset pieDataset = new DefaultPieDataset();


//Adiciona os dados ao dataSet deve somar um total de 100%
        pieDataset.setValue("Skol", new Integer(60));
        pieDataset.setValue("Brahma", new Integer(15));
        pieDataset.setValue("Antártica", new Integer(15));
        pieDataset.setValue("Crystal", new Integer(10));
        //Adiciona os dados ao dataSet deve somar um total de 100%
        DefaultCategoryDataset ds = new DefaultCategoryDataset();
        ds.addValue(0.5, "maximo", "dia 1");
        ds.addValue(38.2, "maximo", "dia 2");
        ds.addValue(37.3, "maximo", "dia 3");
        ds.addValue(31.5, "maximo", "dia 4");
        ds.addValue(35.7, "maximo", "dia 5");
        ds.addValue(42.5, "maximo", "dia 6");

        //    line.addItem("Skol", new Integer(60));
        //     line.setValue("Brahma", new Integer(15));
        //    line.setValue("Antártica", new Integer(15));
        //   line.setValue("Crystal", new Integer(10));

//Cria um objeto JFreeChart passando os seguintes parametros
        JFreeChart grafico = ChartFactory.createPieChart(
                "Consumo Anual de Cerveja", //Titulo do grafico
                pieDataset, //DataSet
                true, //Para mostrar ou não a legenda
                true, //Para mostrar ou não os tooltips
                false);

        JFreeChart grafico1 = ChartFactory.createLineChart3D("Outro", username,
                username, null, PlotOrientation.HORIZONTAL, rootPaneCheckingEnabled,
                rootPaneCheckingEnabled, rootPaneCheckingEnabled);
//                "Consumo Anual de Cerveja", //Titulo do grafico
//                pieDataset, //DataSet
//                true, //Para mostrar ou não a legenda
//                true, //Para mostrar ou não os tooltips
//               false);
        //this.add(new ChartPanel(grafico));

        JFreeChart lineChar = ChartFactory.createLineChart("LineChart", "Corrente", "Corrente", ds,
                PlotOrientation.VERTICAL, true,
                true, true);
        
        im = new ImageIcon(getClass().getResource("/imagens/foto1.jpg")).getImage();
        lineChar.setBackgroundImageAlpha(0.5f);

        lineChar.setBackgroundImage(im);

//                "Consumo Anual de Cerveja", //Titulo do grafico
//                pieDataset, //DataSet
//                true, //Para mostrar ou não a legenda
//                true, //Para mostrar ou não os tooltips
//                false);
//        //this.add(new ChartPanel(grafico));
        jScrollPane1.setViewportView(new ChartPanel(lineChar));
    }

    private JFreeChart createChart(PieDataset dataset, String title) {

        JFreeChart chart = ChartFactory.createPieChart3D(title, // chart title
                dataset, // data
                true, // include legend
                true,
                false);

        PiePlot3D plot = (PiePlot3D) chart.getPlot();
        plot.setStartAngle(290);
        // plot.setDirection(Rotation.CLOCKWISE);
        plot.setForegroundAlpha(0.5f);
        return chart;

    }

    private PieDataset createDataset1() {
        DefaultPieDataset result = new DefaultPieDataset();
        result.setValue("Linux", 29);
        result.setValue("Mac", 20);
        result.setValue("Windows", 51);
        return result;

    }

    private PieDataset createDataset() {
        DefaultPieDataset result = new DefaultPieDataset();


        Date d = new Date();
        int year = d.getYear() + 1900;

//        int corrente = operacao.getSumContaPagReceber(conn, year, finances_comands.RECEITA);
//        int tensao = operacao.getSumContaPagReceber(conn, year, finances_comands.DESPESA);
//
//
//        result.setValue("CORRENTE", corrente);
//        result.setValue("TENSAO", tensao);



        return result;

    }
    Painter<JXMapViewer> textOverlay = new Painter<JXMapViewer>() {
        @Override
        public void paint(Graphics2D g, JXMapViewer map, int w, int h) {
            g.setPaint(new Color(0, 0, 0, 165));
            g.fillRoundRect(65, 10, 182, 30, 10, 10);
            g.setPaint(Color.WHITE);
            g.drawString("Images provided by NASA", 65 + 10, 10 + 20);

        }
    };

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {


        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FormPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }


        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {

                new FormPrincipal("", null).setVisible(true);

            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    public static javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private org.jdesktop.swingx.JXLoginPane jXLoginPane1;
    private org.openstreetmap.gui.jmapviewer.tilesources.MapQuestOpenAerialTileSource mapQuestOpenAerialTileSource1;
    private org.openstreetmap.gui.jmapviewer.OsmMercator osmMercator1;
    private org.openstreetmap.gui.jmapviewer.tilesources.OsmTileSource osmTileSource1;
    private javax.swing.JTabbedPane tabPanel;
    private javax.swing.JTextField txt_avisoSobrecarga;
    private javax.swing.JTextField txt_ccaFA;
    private javax.swing.JTextField txt_ccaFB;
    private javax.swing.JTextField txt_ccaFC;
    private javax.swing.JTextField txt_contAvisoSobrecarga;
    private javax.swing.JTextField txt_contCurtos;
    private javax.swing.JTextField txt_contFalhaTensao;
    private javax.swing.JTextField txt_contSobrecarga;
    private javax.swing.JTextField txt_correnteFA;
    private javax.swing.JTextField txt_correnteFB;
    private javax.swing.JTextField txt_correnteFC;
    private javax.swing.JTextField txt_correnteFN;
    private javax.swing.JTextField txt_data;
    private javax.swing.JTextField txt_estadoChave;
    private javax.swing.JTextField txt_estadoMaquina;
    private javax.swing.JTextField txt_estadoOperacao;
    private javax.swing.JTextField txt_estadoSwitchServico;
    private javax.swing.JTextField txt_falhaCorrente;
    private javax.swing.JTextField txt_falhaSobrecarga;
    private javax.swing.JTextField txt_falhaTensao;
    private javax.swing.JTextField txt_idReligadora;
    private javax.swing.JTextField txt_latitude;
    private javax.swing.JTextField txt_limiteSobrecarga;
    private javax.swing.JTextField txt_longitude;
    private javax.swing.JTextField txt_tempoSobrecarga;
    private javax.swing.JTextField txt_tensaoFA;
    private javax.swing.JTextField txt_tensaoFB;
    private javax.swing.JTextField txt_tensaoFC;
    private javax.swing.JTextField txt_valSobrFA;
    private javax.swing.JTextField txt_valSobrFB;
    private javax.swing.JTextField txt_valSobrFC;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the factory
     */
    public TileFactory getFactory() {
        return factory;
    }

    /**
     * @param factory the factory to set
     */
    public void setFactory(TileFactory factory) {
        this.factory = factory;
    }

    public void getGadosReligadora(int codReligadora) {
        int vet[] = operacao.getDadosReligadora(codReligadora);

        txt_idReligadora.setText("" + vet[0]);
        txt_estadoChave.setText("" + vet[1]);
        txt_estadoMaquina.setText("" + vet[2]);
        txt_falhaTensao.setText("" + vet[3]);
        txt_falhaCorrente.setText("" + vet[4]);
        txt_falhaSobrecarga.setText("" + vet[5]);
        txt_avisoSobrecarga.setText("" + vet[6]);
        txt_contFalhaTensao.setText("" + vet[7]);
        txt_contCurtos.setText("" + vet[8]);
        txt_contSobrecarga.setText("" + vet[9]);
        txt_contAvisoSobrecarga.setText("" + vet[10]);
        txt_ccaFA.setText("" + vet[11]);
        txt_ccaFB.setText("" + vet[12]);
        txt_ccaFC.setText("" + vet[13]);
        txt_valSobrFA.setText("" + vet[14]);
        txt_valSobrFB.setText("" + vet[15]);
        txt_valSobrFC.setText("" + vet[16]);
        txt_limiteSobrecarga.setText("" + vet[17]);
        txt_tempoSobrecarga.setText("" + vet[18]);
        txt_tensaoFA.setText("" + vet[19]);
        txt_tensaoFB.setText("" + vet[20]);
        txt_tensaoFC.setText("" + vet[21]);
        txt_correnteFA.setText("" + vet[22]);
        txt_correnteFB.setText("" + vet[23]);
        txt_correnteFC.setText("" + vet[24]);
        txt_correnteFN.setText("" + vet[25]);
        txt_estadoSwitchServico.setText("" + vet[26]);
        txt_estadoOperacao.setText("" + vet[27]);
        txt_data.setText("" + vet[28]);
        txt_latitude.setText("" + vet[29]);
        txt_longitude.setText("" + vet[30]);

    }

    public void HabilitaCampos() {
        txt_idReligadora.setEnabled(true);
        txt_estadoChave.setEnabled(true);
        txt_estadoMaquina.setEnabled(true);
        txt_falhaTensao.setEnabled(true);
        txt_falhaCorrente.setEnabled(true);
        txt_falhaSobrecarga.setEnabled(true);
        txt_avisoSobrecarga.setEnabled(true);
        txt_contFalhaTensao.setEnabled(true);
        txt_contCurtos.setEnabled(true);
        txt_contSobrecarga.setEnabled(true);
        txt_contAvisoSobrecarga.setEnabled(true);
        txt_ccaFA.setEnabled(true);
        txt_ccaFB.setEnabled(true);
        txt_ccaFC.setEnabled(true);
        txt_valSobrFA.setEnabled(true);
        txt_valSobrFB.setEnabled(true);
        txt_valSobrFC.setEnabled(true);
        txt_limiteSobrecarga.setEnabled(true);
        txt_tempoSobrecarga.setEnabled(true);
        txt_tensaoFA.setEnabled(true);
        txt_tensaoFB.setEnabled(true);
        txt_tensaoFC.setEnabled(true);
        txt_correnteFA.setEnabled(true);
        txt_correnteFB.setEnabled(true);
        txt_correnteFC.setEnabled(true);
        txt_correnteFN.setEnabled(true);
        txt_estadoSwitchServico.setEnabled(true);
        txt_estadoOperacao.setEnabled(true);
        txt_data.setEnabled(true);
        txt_latitude.setEnabled(true);
        txt_longitude.setEnabled(true);
    }

    public void desabilitaCampos() {
        //  txt_idReligadora.setEnabled(false);
        txt_estadoChave.setEnabled(false);
        txt_estadoMaquina.setEnabled(false);
        txt_falhaTensao.setEnabled(false);
        txt_falhaCorrente.setEnabled(false);
        txt_falhaSobrecarga.setEnabled(false);
        txt_avisoSobrecarga.setEnabled(false);
        txt_contFalhaTensao.setEnabled(false);
        txt_contCurtos.setEnabled(false);
        txt_contSobrecarga.setEnabled(false);
        txt_contAvisoSobrecarga.setEnabled(false);
        txt_ccaFA.setEnabled(false);
        txt_ccaFB.setEnabled(false);
        txt_ccaFC.setEnabled(false);
        txt_valSobrFA.setEnabled(false);
        txt_valSobrFB.setEnabled(false);
        txt_valSobrFC.setEnabled(false);
        txt_limiteSobrecarga.setEnabled(false);
        txt_tempoSobrecarga.setEnabled(false);
        txt_tensaoFA.setEnabled(false);
        txt_tensaoFB.setEnabled(false);
        txt_tensaoFC.setEnabled(false);
        txt_correnteFA.setEnabled(false);
        txt_correnteFB.setEnabled(false);
        txt_correnteFC.setEnabled(false);
        txt_correnteFN.setEnabled(false);
        txt_estadoSwitchServico.setEnabled(false);
        txt_estadoOperacao.setEnabled(false);
        txt_data.setEnabled(false);
        txt_latitude.setEnabled(false);
        txt_longitude.setEnabled(false);
    }

    public static class limitaCaracterInteiro extends PlainDocument {

        int valor = 2;

        @Override
        public void insertString(int offs, String str, AttributeSet a)
                throws BadLocationException {
            if (str != null && (getLength() + str.length() < valor)) {
                String sentenca = Normalizer.normalize(str.toUpperCase(), Normalizer.Form.NFD); // elimina os acentos.
                sentenca = sentenca.replaceAll("[^0-9]", "");

                super.insertString(offs, sentenca, a);
            }
        }
    }

    public static class limitaCaracterData extends PlainDocument {

        int valor = 8;

        @Override
        public void insertString(int offs, String str, AttributeSet a)
                throws BadLocationException {
            if (str != null && (getLength() + str.length() < valor)) {
                String sentenca = Normalizer.normalize(str.toUpperCase(), Normalizer.Form.NFD); // elimina os acentos.
                sentenca = sentenca.replaceAll("[^0-9]", "");

                super.insertString(offs, sentenca, a);
            }
        }
    }

    public class SelectionPainter extends MouseAdapter implements Painter<JXMapViewer> {

        private Rectangle rect, start, end;
        private Color borderColor = new Color(0, 0, 200);
        private Color regionColor = new Color(0, 0, 200, 75);

        public SelectionPainter() {
        }

        public void mousePressed(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                rect = null;
                start = null;
            } else {
                start = new Rectangle(e.getPoint());
                ((JXMapViewer) e.getSource()).setPanEnabled(false);
                JPopupMenu popup = new JPopupMenu();
                JMenuItem item3 = new JMenuItem("Teste");
                popup.add(item3);
                popup.show(jxMapKit, 50, 100);
            }
        }

        public void mouseDragged(MouseEvent e) {
            if (start != null) {
                end = new Rectangle(e.getPoint());
                rect = start.union(end);
            }
            ((JXMapViewer) e.getSource()).repaint();
        }

        public void mouseReleased(MouseEvent e) {
            if (start == null) {
                return;
            }
            end = new Rectangle(e.getPoint());
            rect = start.union(end);
            ((JXMapViewer) e.getSource()).setPanEnabled(true);
            ((JXMapViewer) e.getSource()).repaint();
        }

        public void paint(Graphics2D gd, JXMapViewer t, int i, int i1) {
            if (rect != null) {
                gd.setColor(regionColor);
                gd.fillRect(rect.x, rect.y, rect.width, rect.height);
                gd.setColor(borderColor);
                gd.drawRect(rect.x, rect.y, rect.width, rect.height);
            }
        }
    }

    public class MapMarkerDot1 implements MapMarker {

        Color color;
        int id;
        double lat;
        double lon;
        String status;

        public MapMarkerDot1(Color color, int id, Double lat, Double lon, String status) {
            super();
            this.color = color;
            this.id = id;
            this.lat = lat;
            this.lon = lon;
            this.status = status;
        }

        public MapMarkerDot1(double lat, double lon) {
            this(Color.YELLOW, lat, lon);
        }

        public MapMarkerDot1(Color color, double lat, double lon) {
            super();
            this.color = color;
            this.lat = lat;
            this.lon = lon;
        }

        public double getLat() {
            return lat;
        }

        public double getLon() {
            return lon;
        }

        public void paint(Graphics g, String sta) {
            int size_h = 5;
            int size = size_h * 2;
            g.setColor(color);
            // g.fillOval(position.x - size_h, position.y - size_h, size, size);
            g.setColor(Color.BLACK);
            // g.drawOval(position.x - size_h, position.y - size_h, size, size);
            g.drawString("Religadora " + idReligadora + " - " + sta, -60, -43);
        }
        Color indicationColor = Color.green;

        public void paintIndication(Graphics g, Point position) {
            int size_h = 10;
            int size = size_h * 2;

            g.setColor(this.indicationColor);
            g.fillOval(position.x - size_h, position.y - size_h, size, size);
        }

        @Override
        public String toString() {
            return "MapMarker at " + lat + " " + lon;
        }

        @Override
        public void paint(Graphics g, Point position) {
            int size_h = 5;
            int size = size_h * 2;
            g.setColor(color);
            g.fillOval(position.x - size_h, position.y - size_h, size, size);
            g.setColor(Color.BLACK);
            g.drawOval(position.x - size_h, position.y - size_h, size, size);
            /// g.drawString("Religadora "+idReligadora+" - "+sta, -60, -43);
        }
    }

    class Teste extends Thread {

        public void run() {
            List<Status_Religadora> listaRelisgadora = new Operacao().listar();
            for (int i = 0; i < listaRelisgadora.size(); i++) {

                idReligadora = listaRelisgadora.get(i).getId_religadora();
                lat = Double.parseDouble(listaRelisgadora.get(i).getLat());
                lon = Double.parseDouble(listaRelisgadora.get(i).getLon());
                status = listaRelisgadora.get(i).getStatus();

                System.out.println("Passou");
//            System.out.println("Longitude" + lon);
                //waypoints.add(new Waypoint(lat, lon));
                if ("CANC".equals(status)) {
                    //  PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot(Color.RED, lat, lon));
                    MapMarkerDot1 CANC = new MapMarkerDot1(Color.RED, idReligadora, lat, lon, status);
                    // String a  =new MapMarkerDot1(Color.RED,idReligadora, lat, lon, status).toString();

                    PainelMaps.jMapViewer1.addMapMarker(CANC);

                    //                   PainelMaps.jMapViewer1.setToolTipText(a);
//PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot(Color.RED,idReligadora, lat, lon, status));
//PainelMaps.jMapViewer1.add
//                System.out.println(idReligadora + ": "+lat+ " : "+lon+ " : "+status);

                } else if ("OPEN".equals(status)) {
                    // PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot(Color.YELLOW, lat, lon));
                    MapMarkerDot1 OPEN = new MapMarkerDot1(Color.YELLOW, idReligadora, lat, lon, status);

                    //  MapMarkerDot1 TESTE = new MapMarkerDot1
                    PainelMaps.jMapViewer1.addMapMarker(OPEN);

                    // PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot1(Color.YELLOW,idReligadora, lat, lon, status));
                    // System.out.println(idReligadora + ": "+lat+ " : "+lon+ " : "+status);
                } else {
                    //PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot(Color.GREEN, lat, lon));
                    MapMarkerDot1 ATIVO = new MapMarkerDot1(Color.GREEN, idReligadora, lat, lon, status);
                    PainelMaps.jMapViewer1.addMapMarker(ATIVO);
                    //   PainelMaps.jMapViewer1.addMapMarker(new MapMarkerDot1(Color.GREEN,idReligadora, lat, lon, status));
                    System.out.println(idReligadora + ": " + lat + " : " + lon + " : " + status);
                }
                System.out.println("Posicao: " + i + " - ID: " + idReligadora + " - Status: " + status);
                JMenuItem item3 = new JMenuItem("" + lat + "" + lon);
                JPopupMenu popup = new JPopupMenu();
                popup.add(item3);
                // popup.show();
                //  jMapViewer1.add(popup);]

                popup.show(PainelMaps.jMapViewer1, 50, 50);
            }
        }
    }
    public class Clock implements ActionListener { 

   private javax.swing.Timer timer; 
  

   public Clock(){ 
     
      disparaRelogio(); 
   } 
   

   public void disparaRelogio() { 
      if (timer == null) { 
         timer = new javax.swing.Timer(1000, this); 
         timer.setInitialDelay(0); 
         timer.start(); 
      } else if (!timer.isRunning()) { 
         timer.restart(); 
      } 
   } 

   public void actionPerformed(ActionEvent ae) { 
      GregorianCalendar calendario = new GregorianCalendar(); 
      int h = calendario.get(GregorianCalendar.HOUR_OF_DAY); 
      int m = calendario.get(GregorianCalendar.MINUTE); 
      int s = calendario.get(GregorianCalendar.SECOND); 

      String hora = 
         ((h < 10) ? "0" : "") 
            + h 
            + ":" 
            + ((m < 10) ? "0" : "") 
            + m 
            + ":" 
            + ((s < 10) ? "0" : "") 
            + s; 

      jLabel35.setText(hora); 
   } 
   
} 
}